<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title>JavaScript String Test</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		
		<style type="text/css">
			div#header {
				color: #0066FF;
				font-size: 25pt;
			}
			
			div#content {
				color: #B088FF;
				font-size: 12pt;
			}
		</style>
		
		<!-- embed jquery by google，藉由google嵌入jquery 1.6.2 -->
		<script type="text/javascript" src="http://www.google.com/jsapi"></script>
		<script type="text/javascript" language="javascript">
			google.load( "jquery", "1.6.2" );
		</script>
		<script type="text/javascript">
			
			// 建構子函式
			function User( name, age ) {
				
				var _name = name;
				var _age  = age;
				
				this.toString = function() {
					var detailMsg = "This user's info are <br />"
					var result 	  = detailMsg + "Name: " + name + " ,Age: " + age + "<br /><br />"
					
					return result;
				};
			}
			
			function isTargetNullOrEmptyString( target ) {
				
				var result = false;
				
				if ( null == target ) {
					result = true;
				}
				
				if ( typeof( target ) == "string" && target == "" ) {
					result = false;
				}
				
				return result;
			}
		
			$( document ).ready( function() {
				
				var $content   = $( "#content" );
				var prettyGirl = new User( "Vivian", 21 );
				var message	   = "";
				
				message += prettyGirl.toString();
				message += prettyGirl + "";
				message += prettyGirl;
				
				var ulgyGirl = null;
				var msg 	 = "";
				
				// message += ulgyGirl.toString();
				msg += ulgyGirl + "";
				msg += ulgyGirl;
	
				// 測試方法用，我的寫的方法正確無誤!
				// alert( "空字串 " + isTargetNullOrEmptyString( "" ) );
				// alert( "null值 " + isTargetNullOrEmptyString( null ) );
				
				var targetObj = ulgyGirl + "";  // 參考到一個字串內容為null的字串，不是null值，也不是空字串喔! 超怪!
				var string 	  = "";
				if ( isTargetNullOrEmptyString( targetObj ) ) {
					string += "參考到null值"
					alert( string );
				} else {
					string += targetObj;
					alert( string );
				}
				
				$content.html( message + msg );
			});
		</script>
		
	</head>
	
	<body>
		<div title="temp1" id="header">JavaScript String Test</div>
		<div title="temp2" id="content">
			hello!
		</div>
	</body>
</html>